package com.pro.framework.api.util;


import com.pro.framework.api.model.FrameworkException;

import java.util.List;

public class AssertUtil {

    public static <T> List<T> notEmpty(List<T> o, String errorMsgTemplate, Object... param) {
        if (null == o || o.isEmpty()) {
            throw new FrameworkException(errorMsgTemplate, param);
        }
        return o;
    }

    public static String notEmpty(String o, String errorMsgTemplate, Object... param) {
        if (null == o || o.isEmpty()) {
            throw new FrameworkException(errorMsgTemplate, param);
        }
        return o;
    }

    public static <T> T notEmpty(T o, String errorMsgTemplate, Object... param) {
        if (null == o) {
            throw new FrameworkException(errorMsgTemplate, param);
        }
        return o;
    }

    public static <T> void empty(T o, String errorMsgTemplate, Object... param) {
        if (null != o) {
            throw new FrameworkException(errorMsgTemplate, param);
        }
    }


    public static void isTrue(Boolean flag, String errorMsgTemplate, Object... param) {
        if (null == flag || !flag) {
            throw new FrameworkException(errorMsgTemplate, param);
        }
    }

//    public static <T> T equal(T v1, T v2) {
//        if (v1.equals(v2)) {
//            throw new FrameworkException("must equal");
//        }
//        return v1;
//    }

}
